/* eslint-disable @typescript-eslint/no-explicit-any */
import { _decorator, Component } from 'cc';
import { EffectManager } from '../../Manager/EffectManager';
import { CallBackHandler } from '../PoolObj/CallBackHandler';

/*
 * @Author: Hp_lucky 1063512385@qq.com
 * @Date: 2024-09-28 14:34:03
 * @LastEditors: Hp_lucky 1063512385@qq.com
 * @LastEditTime: 2024-10-14 09:49:59
 * @FilePath: \lucky-rpg\assets\script\src\Basic\Model\Effect\Effect.ts
 */
const { ccclass } = _decorator;

@ccclass('Effect')
export abstract class Effect extends Component {
  effectId: number = 0;
  effParam: string = '';
  param: any;
  loop: number = 0;
  callBack: CallBackHandler;

  reuse(id: number, effParam: string, param?: any, callBack?: CallBackHandler, loop?: number) {
    this.effectId = id;
    this.effParam = effParam;
    this.param = param;
    this.callBack = callBack;
    this.loop = loop ?? 1;
    this.node.setPosition(0, 0);
    this.node.angle = 0;
  }

  unuse() {
    // this.node.removeAllChildren();
    this.callBack?.execute();
    this.callBack = null;
    EffectManager.Ins().releaseEffect(this.node);
  }
}
